import cn.acmenms.manager.tomcat.TomcatManager;
import cn.acmenms.manager.tomcat.TomcatManagerResponse;
import org.testng.annotations.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.Properties;

/**
 * @ClassName: TomcatManagerDeploy
 * @Description: 用于调试 tomcatManager 远程部署
 * @author: 神奇的鸭鸭
 * @Date: 2017/12/7 10:04
 */
public class TomcatManagerDeploy {

    public static void main(String[] args) throws Exception {
        Properties pro = new Properties();
        // 保密信息
        FileInputStream in = new FileInputStream("E:\\MyCode\\Server.properties");
        pro.load(in);
        String url = pro.getProperty("url");
        String username = pro.getProperty("username");
        String password = pro.getProperty("password");
        in.close();

        TomcatManager tm = new TomcatManager(new URL(url), username, password);
        File war = new File("E:\\MyCode\\oscGit\\AcmenMS\\AcmenMS-web\\target\\AcmenMS.war");
        TomcatManagerResponse response = tm.deploy(war, true);
        System.out.println(response.getHttpResponseBody());// OK - Deployed application at context path /AcmenMS.war
        System.out.println(response.getStatusCode());// 200
    }
}